import { DialogBase } from "../../common/displayBg/DialogBase";
import { LayerManager } from "../../../manager/LayerManager";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { ObjCreate } from "../../common/ObjCreate";
import { SGetBossQuestion } from "../../../../../Message/Public/SGetBossQuestion";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
//class GuildCopyQuestionDialog
    
    export  class GuildCopyQuestionDialog extends DialogBase
    {
        constructor()
        {
            super();
            this.layer = LayerManager.windowLayer;
            var loc1=GameDefConfig.instance.getGuildCopyQuestionNpc();
            if (loc1) 
            {
                this.dialogHead = loc1.name;
            }
            return;
        }

        protected /* override */ initUI(): void
        {
            super.initUI();
            title = "";
            this._answerA = ObjCreate.createGTextField("", 200, 100, 300, 20, this);
            this._answerB = ObjCreate.createGTextField("", 200, 120, 300, 20, this);
            this._answerA.addEventListener(flash.events.TextEvent.LINK, this.onAnswerClick);
            this._answerB.addEventListener(flash.events.TextEvent.LINK, this.onAnswerClick);
            return;
        }

        public setTitle(arg1: string): void
        {
            title = arg1;
            dialogName = arg1;
            return;
        }

        public updateQuestion(arg1: SGetBossQuestion): void
        {
            this._question = arg1;
            desc = arg1.questionName;
            this._answerA.htmlText = HTMLUtil.addColor("<a href=\'event: a\'><u>A、" + arg1.a + "</u></a>", "#FFFF00");
            this._answerB.htmlText = HTMLUtil.addColor("<a href=\'event: b\'><u>B、" + arg1.b + "</u></a>", "#FFFF00");
            return;
        }

        /* internal  */onAnswerClick(arg1: Object /* flash.events.TextEvent */): void
        {
            var loc1=new Object();
            loc1["entityId"] = this._question.entityId;
            var loc2=arg1.text;
            switch (loc2) 
            {
                case "a":
                {
                    loc1["answer"] = this._question.a;
                    break;
                }
                case "b":
                {
                    loc1["answer"] = this._question.b;
                    break;
                }
                case "c":
                {
                    loc1["answer"] = this._question.c;
                    break;
                }
                case "d":
                {
                    loc1["answer"] = this._question.d;
                    break;
                }
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildCopyAnswerBossQuestion, loc1));
            this.hide();
            return;
        }

        /* internal */ /* var */_question: SGetBossQuestion;

        /* internal */ /* var */_answerA: GTextFiled;

        /* internal */ /* var */_answerB: GTextFiled;

        /* internal */ /* var */_answerC: GTextFiled;

        /* internal */ /* var */_answerD: GTextFiled;
    }
